public class Demo02 {
    //饿汉模式
    public static void main(String[] args) {
        SingletonHungry singletonHungry = new SingletonHungry();
        SingletonHungry instance1 = singletonHungry.getInstance();
        SingletonHungry instance2 = singletonHungry.getInstance();
        SingletonHungry instance3 = singletonHungry.getInstance();
        System.out.println(instance1);
        System.out.println(instance2);
        System.out.println(instance3);
    }
}

class SingletonHungry {
    private static SingletonHungry instance = new SingletonHungry();
    public SingletonHungry() {}
    public static SingletonHungry getInstance() {
        return instance;
    }
}